<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script src="./vue.js"></script>
    <script src="https://unpkg.com/vue-router@3.5.1/dist/vue-router.js"></script>
</head>
<!--组件也有生命周期
-->

<body>

    <div id="a">
        <router-link to='login?id=10&name="zs"'>登录</router-link>
        <!-- 传参不需要改变路径 -->
        <router-link to='register'>组测</router-link>
        <router-view></router-view>
    </div>

    <script>
        var login = {
            template: '<p>登录组件{{$route.query.id}}---{{$route.query.name}}</p>',

        };
        var register = {
            template: '<p>注册组件</p>'
        };
        var rounterObject = new VueRouter({
            routes: [{
                path: '/',
                redirect: '/login'
            }, {
                path: '/login',
                component: login
            }, {
                path: '/register',
                component: register
            }]
        })
        new Vue({
            el: '#a',
            data: {},
            methods: {},
            router: rounterObject
        })
    </script>
</body>

</html>